let enumIdList = new Array();

/**
 * zmn文章模块-文章编辑
 * 文件命名格式：zmn.模块.表/功能.jas
 * @author heguanghua
 * @since 2018/10/18
 */
layui.define(['form', 'layedit', 'laydate'], function (exports) {
    let $ = layui.$;
    let form = layui.form;
    let layer = layui.layer;
    let layedit = layui.layedit;
    let laydate = layui.laydate;
    let index;

    form.verify({
        templateType: function(value){
            var val = $("input[name='templateType']:checked").val();
            return val == null ? "请选择类型" : "";
        },
        minSort: function(value, item){ //value：表单的值、item：表单的DOM对象
            if (value < 1){
                return "排序号不能小于1";
            }
            if (value > 10000000){
                return "排序号不能大于10000000";
            }
        },
        isPositiveNumber: function(value,item){
            if (!/^[0-9]+$/.test(value)) {
                return "排序值只能是正整数";
            }
        }
    });

    // zmnLayUtil.layFormVerify(form);

    // 提交
    form.on('submit(zmn-form-submit)', function(obj){
        var data = obj.field;

        var url = "/msg/temp/addEdit.action";
        $.ajax({
            async: false,
            type: "POST", url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            success:function(json) {
                var message = json.status == 200 ? "操作成功！" : json.message;
                layer.msg(message);
                if(json.status == 200) {
                    zmnPage.direct("/msg/temp/content.action?templateId=" + json.data, 0);
                }
            },
            error:function(XMLHttpRequest, status, errorThrown){}
        });
        return false;
    });


    //对外暴露的接口
    exports('msg_template_edit', {});
});